<?php

class Workset_Model_Object_Registry extends SplObjectStorage {

    protected static $_namespaces = array();

    static function getNamespaceInstance($namespace) {
        $namespace = (string)$namespace;

        if (!isset(self::$_namespaces[$namespace])) {
            self::$_namespaces[$namespace] = new self();
        }
        
        return self::$_namespaces[$namespace];
    }

    static function add($namespace, $object, $data = null) {
        $storage = self::getNamespaceInstance($namespace);
        $storage->attach($object, $data);
    }

    static function remove($namespace, $object) {
        $storage = self::getNamespaceInstance($namespace);
        $storage->detach($object);
    }

    function attach(Workset_Model_Object_Interface $object, $data = null) {
        parent::attach($object, $data);
    }

    function detach(Workset_Model_Object_Interface $object) {
        parent::detach($object);
    }

}

